package com.project.service.impl;

import com.project.bean.CarBean;
import com.project.mapper.ICarMapper;
import com.project.service.ICarSercie;
import org.apache.ibatis.session.SqlSession;

public class CarServiceImpl extends BaseService implements ICarSercie {
    @Override
    public void add(CarBean car, int manId) {
        SqlSession session = this.getSession();
        ICarMapper mapper = session.getMapper(ICarMapper.class);
        mapper.add(car,manId);
        session.commit();
        session.close();
    }

    @Override
    public CarBean findByIdIncludeMan(int id) {
        SqlSession session = this.getSession();
        ICarMapper mapper = session.getMapper(ICarMapper.class);
        CarBean car = mapper.findByIdIncludeMan(id);
        session.close();
        return car;
    }

    public static void main(String[] args) {
        ICarSercie sercie = new CarServiceImpl();
//        sercie.add(new CarBean("布加迪",20000000), 5);
        System.out.println(sercie.findByIdIncludeMan(9));
    }
}
